Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joint hypotheses #94

Merged

Conversation

LamAdr
Copy link
Contributor

@LamAdr LamAdr commented Mar 5, 2024

Here is my go at joint hypotheses testing. It seems pymarginaleffects does not support making hypotheses about comparisons/slopes objects yet, and I didn't change that. I made changes to two other files :

  1. classes.py
  • added the capability to change the mapping used to change column names at print time
  • added a dataframe header print_head to match R's output
  1. model_statsmodel.py
  • get_variables_names() now keeps the variables in the order they appear in the formula. That's useful if users want to specify which variable they're hypothesizing on based on their indices.
  • added the get_df function

One potentially problematic assumption is that the presence of the intercept is verified with len(theta_hat) == len(var_names)+1.

Thanks

@vincentarelbundock
Copy link
Owner

Thanks! Are the tests hard-coded numbers verified against R?

FYI, I'm not planning to allow hypotheses() to process slopes or comparisons or predictions objects. I regret this design choice in R. Users should just use the hypothesis argument instead of a separate function call.

@LamAdr
Copy link
Contributor Author

LamAdr commented Mar 5, 2024

Are the tests hard-coded numbers verified against R?

You mean as in e.g.

hypo_py = hypotheses(mod, joint=[0, 1, 2], hypothesis=[1, 2, 3])

? If so, yes, I generated a csv using the corresponding R call.

I'm not planning to allow hypotheses() to process slopes or comparisons or predictions objects.

In that case maybe we should rename the input obj to model or mod?

@vincentarelbundock
Copy link
Owner

Let's do exact parallelism in argument names between R and Python, even if it feels a bit weird.

Let me know when I can merge. Looks great!

@LamAdr
Copy link
Contributor Author

LamAdr commented Mar 5, 2024

alright, I think you can merge.

@vincentarelbundock vincentarelbundock merged commit dd66f61 into vincentarelbundock:main Mar 5, 2024
5 checks passed
@vincentarelbundock
Copy link
Owner

great thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants